package com.lzb.common.datasource;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

public class MultipleDataSource extends AbstractRoutingDataSource {
	
	public static final String DATA_SOURCE_LOCALHOST = "localhostDataSource";
	public static final String DATA_SOURCE_MASTER = "masterDataSource";
	public static final String DATA_SOURCE_SLAVE_1 = "slave1DataSource";
    private static final ThreadLocal<String> dataSourceKey = new InheritableThreadLocal<String>();

    public static void setDataSourceKey(String dataSource) {
        dataSourceKey.set(dataSource);
    }

    @Override
    protected Object determineCurrentLookupKey() {
        return dataSourceKey.get();
    }
}